package com.gt.aep.base.service.systemManage;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gt.aep.base.dao.systemManage.SysPermissionIdentityRoleDao;
import com.gt.aep.base.entity.systemManage.SysPermission;
import com.gt.aep.base.entity.systemManage.SysPermissionIdentityRole;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysPermissionIdentityRoleService {

    @Autowired
    SysPermissionIdentityRoleDao sysPermissionIdentityRoleDao;

    /**
     * 新增身份角色-权限关系
     * @param sysPermissionIdentityRole
     * @return
     */
    public int insert(SysPermissionIdentityRole sysPermissionIdentityRole){
        return sysPermissionIdentityRoleDao.insert(sysPermissionIdentityRole);
    }

    /**
     * 修改身份角色-权限关系
     * @param sysPermissionIdentityRole
     * @return
     */
    public int update(SysPermissionIdentityRole sysPermissionIdentityRole){
        return sysPermissionIdentityRoleDao.update(sysPermissionIdentityRole);
    }

    /**
     * 批量删除身份角色-权限关系
     * @param ids
     * @return
     */
    public int delete(String[] ids){
        return sysPermissionIdentityRoleDao.delete(ids);
    }

    /**
     * 根据用户id查询身份角色列表
     * @param pid 权限id
     * @return
     */
    public List<SysPermissionIdentityRole> getListByPid(String pid){
        return sysPermissionIdentityRoleDao.getListByPid(pid);
    }

    /**
     * 根据身份角色id查询权限个数
     * @param pid
     * @return
     */
    public int getCountByUid(String pid){
        return sysPermissionIdentityRoleDao.getCountByPid(pid);
    }

    /**
     * 根据身份角色id获取列表
     * @param identityRoleId 身份角色id
     * @return
     */
    public List<SysPermission> getListByIdentityRoleId(String identityRoleId){
        return sysPermissionIdentityRoleDao.getListByIdentityRoleId(identityRoleId);
    }

    /**
     * 根据身份角色id获取符合的权限个数
     * @param identityRoleId
     * @return
     */
    public int getCountByIdentityRoleId(String identityRoleId){
        return sysPermissionIdentityRoleDao.getCountByIdentityRoleId(identityRoleId);
    }

    /**
     * 清除identityRid相关记录
     * @param identityRoleId
     * @return
     */
    public int deleteByIdentityRid(String identityRoleId) {
        return sysPermissionIdentityRoleDao.deleteByIdentityRid(identityRoleId);
    }

    /**
     * 清除权限id相关记录
     * @param pid
     * @return
     */
    public int deleteByPid(String pid) {
        return sysPermissionIdentityRoleDao.deleteByPid(pid);
    }
}
